import config from "../config";

console.log("加载了拦截器");

uni.addInterceptor('request', {
	invoke(args) {
		// request 触发前拼接 url
		const token = uni.getStorageSync('token') || ''
		args.url = config.BASE_URL + args.url
		args.header = { ...args.header, token }
	},
	success(args) {
		// 请求成功后，修改code值为1
	},
	fail(err) {
		console.log('interceptor-fail', err)
	},
	complete(res) {
		console.log('interceptor-complete', res)
	}
})
